using System;

namespace PomodoroSuite.FW.Comun.Apoyo
{
    public class TypeHelper
    {
        #region " Fields "

        #endregion

        #region " Constructor "

        #endregion

        #region " Methods "

        public static object GetProperTypeInstance(Type baseType, Type[] genericArguments, params object[] constructorArguments)
        {
            object instance = null;
            if (genericArguments != null && genericArguments.GetLength(0) != 0)
            {
                Type genericType = baseType.MakeGenericType(genericArguments);
                instance = Activator.CreateInstance(genericType, constructorArguments);
            }
            else
                instance = Activator.CreateInstance(baseType, constructorArguments);

            return instance;
        }

        #endregion
    }
}
